package com.dc.server.pay.strategy.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.dc.server.entity.BankPayEntity;
import com.dc.server.entity.OrdersEntity;
import com.dc.server.pay.Pay;
import com.dc.server.pay.strategy.BankStrategy;
import com.dc.server.service.BankPayService;
import com.dc.server.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;

import java.math.BigDecimal;

/**
 * @Auther: 赵聪
 * @Date: 2018/8/25 09:07
 * @Description:
 */
@Pay("CMB")
public class CMBBankStrategy implements BankStrategy {
    @Autowired
    private OrdersService ordersService;
    @Autowired
    private BankPayService bankPayService;
    @Override
    public BigDecimal strategyPayInterface(String code, Integer orderId) {
        OrdersEntity ordersEntity = ordersService.selectById(orderId);
        BankPayEntity bankPayEntity = bankPayService.selectOne(new EntityWrapper<BankPayEntity>().eq("code", code));
        System.out.println("这是招商");
        return ordersEntity.getPrice().multiply(bankPayEntity.getRate());
    }
}
